<template>
<div>
  <van-nav-bar
      :title="title"
      :left-text="text"
      :left-arrow="iconshow"
      @click-left="goBack"
  />
</div>
    <!--style="position: sticky; top: 0"-->
</template>

<script>
export default {
  name: "TopBar",
  data(){
    return{
      text:'',
    }
  },
  methods:{
    goBack() {
      this.$router.go(-1);
        // this.$router.back();
    }
  },

  props:{  //props
    'title': {
      type: String,
      required: true
    },
    'iconshow':{
      type: Boolean,
      default: false
    },
    'hasText':{
      type: Boolean,
      default: false
    }
  },

  mounted() {
    if(this.hasText === true) this.text="返回"
  }
}
</script>

<style scoped>
div{
  background: rgb(252, 252, 252);
}
div:has(div.van-nav-bar){
    position: sticky;
    top: 0;
    z-index: 100;
}
</style>